<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\shop\model;

use think\Db;
use think\Model;

class ShippingModel extends Model
{
    protected $type = [
        'more' => 'array',
    ];

    function update_shipping($order_id){
        $this->where('order_id',$order_id)->delete();
        $order=new OrderModel();
        $orders_info=$order->get_order_detail($order_id);
        $shipping_info=Db::name('logistics')->where('id',$orders_info['shipping_company_id'])->find();
        $data['shippercode']=$shipping_info['logistics_100code'];
        $data['logisticcode']=$orders_info['shipping_code'];
        $rs=hook_one('get_shipping_info_juhe',$data);
        $info['order_id']=$order_id;
        $info['shipping_code']=$orders_info['shipping_code'];
        $info['shipping_company']=$shipping_info['logistics_code'];
        $info['shipping_info']=$rs;
        $orders_info['shipping']=$info;
        $this->insert($info);
    }
}
